﻿using SqlSugar;

namespace ConsoleApp1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string c1 = "Server=10.10.1.38; User Id=WMSDBA;PWD=wmdba123456;SCHEMA=WMSDBA;DATABASE=DAMENG";
            string c2 = "Data Source=59.110.231.187;Initial Catalog=WMSPlatform;User ID=sa;Password=1qaz@WSX;Trust Server Certificate=True;";
            using (SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString = c1,
                DbType = DbType.Dm,
                IsAutoCloseConnection = true,
                MoreSettings = new ConnMoreSettings()
                {
                    IsAutoToUpper = false,
                    DisableMillisecond = true
                }

            },
            db =>
            {

                db.Aop.OnLogExecuting = (sql, pars) =>
                {

                    //获取原生SQL推荐 5.1.4.63  性能OK
                    Console.WriteLine(UtilMethods.GetNativeSql(sql, pars));

                    //获取无参数化SQL 对性能有影响，特别大的SQL参数多的，调试使用
                    //Console.WriteLine(UtilMethods.GetSqlString(DbType.SqlServer,sql,pars))


                };
                db.Aop.OnError = x =>
                {
                    Console.WriteLine(1111);
                };


            }
            ))
            {

                //var accountList = db.Queryable<ACCOUNT>().ToList();

                //创建表：根据实体类CodeFirstTable1  (所有数据库都支持)    
                //db.CodeFirst.InitTables(typeof(PMSLog));//这样一个表就能成功创建了

                db.DbFirst
                    .IsCreateAttribute()
                    .Where(name => name==("FullBoxRecords"))
                    .StringNullable()
                    .CreateClassFile("F:\\MyWork\\DongFangGuoKai\\Project\\浙江杭州计量研究院\\MyCode\\api\\hzjly\\HangZhouJiLiangYuan\\DongFangGuoKai.WMSPlatform.Domain\\Model", "Model");

                //  var list= db.Queryable<t_QueceRecard>().ToList();
            }

        }


    }
}
